package com.lgj.web.route.controller;

import com.lgj.web.route.model.GatewayRoute;
import com.lgj.web.route.service.GateWayRouteService;
import com.lgj.result.ResultBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author guangjie.liao
 * @Date: 2022/10/28 18:24
 * @Description:
 */
@RestController
@RequestMapping("/route")
public class GateWayRouteController {

    @Autowired
    private GateWayRouteService gateWayRouteService;

    @PostMapping
    public ResultBody addRule(GatewayRoute gatewayRoute){
        return gateWayRouteService.addRule(gatewayRoute);
    }

    @GetMapping
    public ResultBody queryRule(String routeName,String serverId,Integer pageSize,Integer pageIndex){
        return gateWayRouteService.queryRule(routeName, serverId, pageSize, pageIndex);
    }

    @GetMapping("/{id}")
    public ResultBody getRule(@PathVariable("id") Long id){
        return gateWayRouteService.getRule(id);
    }

    @PutMapping
    public ResultBody editRule(GatewayRoute gatewayRoute){
        return gateWayRouteService.editRule(gatewayRoute);
    }

    @DeleteMapping
    public ResultBody deleteRule(Long id){
        return gateWayRouteService.deleteRule(id);
    }

}
